package com.guijq.selfcode.javacodeoptimize;

import java.util.Arrays;
import java.util.List;

/**
 * @author yangjf
 * @time 2019-07-05 16:21
 */
public class StreamTest {
    public static void main(String[] args) {
        List<String> names = Arrays.asList("张三", "李四", "王老五", "李三", "刘老四", "小二", "张四", "张五六七");

        int maxLenStartWithZ = names.stream()
                .filter(name -> name.startsWith("张"))
                .mapToInt(String::length)
                .max().getAsInt();

        System.out.println(maxLenStartWithZ);
//        List<String> strings = Arrays.asList("ABC", "CDD","AA");
//        int longestStringLengthStartingWithA
//                = strings.stream()
//                .filter(s -> s.startsWith("A"))
//                .mapToInt(String::length)
//                .max().getAsInt();
//        System.out.println(longestStringLengthStartingWithA);

    }
}
